import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import '@/icons' // icon
import '@/permission' // permission control
import perm from './permission/index'
import VueAMap from 'vue-amap'
Vue.use(VueAMap)
VueAMap.initAMapApiLoader({
  // 申请地址 https://lbs.amap.com/ 选择web端jsAPI
  key: '45cff91a18bf0f54ae65a91708689aa5',
  // 插件集合，用到什么插件就使用什么插件
  plugin: [
    'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PlaceSearch', 'AMap.Autocomplete', 'AMap.Geolocation', 'AMap.Geocoder', 'AMap.AMapUI'
  ],
  v: '1.4.4' // 高德sdk版本，最新的sdk已经出到了2.0
  // 官网解释：JSAPI 2.0 提供的开发接口与 1.4 版本达到 99%的兼容度，但是为了保证插件的稳定性我们还是选择1.4.4。
})
window._AMapSecurityConfig = { securityJsCode: 'ad0ecede17ef85be8cd70b0e5ac223d5' }

// 自定义表格工具扩展
import RightToolbar from '@/components/RightToolbar'
Vue.component('RightToolbar', RightToolbar)
// 富文本框
import RichText from '@/components/RichText'
Vue.component('RichText', RichText)

// 判断权限:这种是:disabled="$hasBP('bnt.sysUser.add') === false" 控制是否可编辑
import hasBtnPermission from '@/utils/btn-permission'
Vue.prototype.$hasBP = hasBtnPermission

// 自定义按钮权限控制(v-perm="['bnt.sysUser.add']"),获取用户信息时就要把权限菜单定义好
// 实现：创建permission文件夹，二文件,index.js(负责注册你的组件名称),
// perm.js(从store仓库中拿到你所有权限标识符对比,有就显示,没就隐藏)
Vue.use(perm)

// import { ElementTiptapPlugin } from 'element-tiptap'
// Vue.use(ElementTiptapPlugin, { lang: 'zh' })

import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
Vue.use(mavonEditor)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

import htmlToPdf from '@/utils/htmlToPdf'
Vue.use(htmlToPdf)

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
